// pages/walk/walk.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperCurrent: "",  //指示点
    //轮播图
    turnImg: ['https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/news1.png', 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/news2.png', 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/news3.png', 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/news4.png'],
    turnText: ['洞口县古楼乡开展新时代文明实践活动', '古楼乡开展“迎老乡、回故乡、建家乡”活动', '几经修缮百年古楼风采依旧', '东昌府区古楼街道：聚焦重点项目 奋力打造“首善街区”头号工程'],
    //用户发帖
    userArticle: [
      {
        imgSrc: 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/阅江楼.png',
        title: '阅江楼美景无比震撼',
        username: '楼楼古香',
        uploadTime: '2023/7/10'
      },
      {
        imgSrc: 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/岳阳楼.png',
        title: '清晨是观赏岳阳楼的绝佳时间',
        username: '守楼1号选手',
        uploadTime: '2023/7/2'
      },
      {
        imgSrc: 'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/全椒太平古城雕画.jpg',
        title: '全椒太平成的古城雕画也太完美了！',
        username: '小小勒',
        uploadTime: '2023/7/1'
      },
    ],
    //商品类别
    tabList:['热门推荐','地方特产','古楼周边'],
    currentTab:0,
    //商品
    shoppingList1:[
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/帆布包.jpg',
        title:'清雅帆布包',
        price:'22.9',
        sales:'30',
        details:'有多重品类可选'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/瓷碗.jpg',
        title:'小瓷器',
        price:'39.9',
        sales:'21',
        details:'品质摆件'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/守味狸香囊.jpg',
        title:'守味狸香囊',
        price:'9.9',
        sales:'16',
        details:'精美周边'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/印章明信片.jpg',
        title:'印章明信片',
        price:'12.9',
        sales:'9',
        details:'一盒装'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/杜甫江阁画作.jpg',
        title:'杜甫江阁画作',
        price:'45.9',
        sales:'3',
        details:'挂饰'
      }
    ],
    leftList1:[],
    rightList1:[],
    shoppingList2:[
      {
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3LMsUiaD2L0ZwfTF3TKEcZ0RDbeC4leG75EtDOU87ia0qWRISAUZqlPNdw/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'郫县豆瓣',
        price:'19.9',
        details:'四川特产，味美鲜香'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3L4llhWfUladBS5AqhaN3mSYy6fB1NNriaJQt7xL4wtXAia68jcRNIDusw/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'蒙山茶',
        price:'45.9',
        details:'四川特产'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3Le6xGycw3T2dkoEMKj152tM2deicjFJYW46sNjvia6JJhH40W24Vibqg6Q/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'苍溪猕猴桃',
        price:'29.9',
        details:'四川特产，果肉细嫩、香气浓郁'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrefY8p1KRC2WovvqSfyrAlVsosNBuU73ibyfENa6UTe8FfQz9IPzxdTicDkZXic8sjhXqvWj32I4ePvBA/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'那曲冬虫夏草',
        price:'27.8',
        details:'西藏著名的中草药特产'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrefY8p1KRC2WovvqSfyrAlVsmaHH1HuXVfGzOib7eNOXZ4P3adtsnxV83CsIkLxxtBoQ5iajficLg4licw/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'西藏自治区山南市隆子县地方特产',
        price:'19.9',
        details:'西藏青稞尤其以隆子黑青稞、察雅黑青稞、乃东青稞最为著名'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrefY8p1KRC2WovvqSfyrAlVsZHBlbjb8qdenlPy3KP7H5dnz2REjDciclbFvNEgvVRnFCL9yBwIIXNg/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'风干牦牛肉',
        price:'79.9',
        details:'西藏著名精选鲜高原牦牛肉自然风干晾晒而成'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrecLSdcmtTkXGOW5yFsZYLYmsMF3PG1WMUGJJQkec2dU4b6WsqvuicjjJYDvUeSPxW6WzRjJn9ibpeibQ/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'文山三七',
        price:'39.9',
        details:'文山三七云南省特有的名贵中药材'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrecLSdcmtTkXGOW5yFsZYLYmKSEIcmj7ibImyicDJAAd0SaYHYwuQ2sySN1NbpvfgrBt344DkEkxuqRQ/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'普洱茶',
        price:'59.9',
        details:'普洱茶是云南省最具代表性的特产茶叶'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyrecLSdcmtTkXGOW5yFsZYLYmWMZbfNIQiaMdzd7I5eBU6QJnuRv1eA1InZmOEOwy3VAR9ostyn7JoTQ/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'建水紫陶',
        price:'129',
        details:'建水紫陶是云南省红河哈尼族彝族自治州建水县地方特产'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3LHvOB8WAAicwCxrR8Osl0stz8GqPf1HmWibdJJ4Maz0xM7icKia21iaibCoOA/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'佳县红枣',
        price:'19.9',
        details:'陕西特产，果大核小，皮薄肉厚'
      },
      {
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3LsOyHjCdVS9cNBSgec0jEbZHFdNPdY7P9rMSibniaK3jQyPmEk2gAQJ6g/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'临潼石榴',
        price:'19.9',
        details:'陕西特产，集全国石榴之优'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3LCoNIzmicqiciaHohNxiaCRhcY1Ae2TKmEa2CKL4qUzBX3UdicmL68DokyGw/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'洋县黑米',
        price:'6.6',
        details:'陕西特产，外皮墨黑，内芯雪白'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3L3Fnh448V4vz4ianZRUZumkrsiaN0OfvM0MJFQdL5nQEulV1ps51Ikw1Q/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'汉中仙毫',
        price:'116',
        details:'陕西特产，香气高锐持久'
      },{
        imgSrc:'https://mmbiz.qpic.cn/mmbiz_jpg/SDDMwelyreeEVSKZZqS7NCpPryvfMp3LtIPf8pNpAIS1RE67YPGMatxdD9FD0Av96l7CJWqRZxR5aHyl0PJUlA/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        title:'景德镇陶瓷',
        price:'31',
        details:'江西特产，白如玉、明如镜、薄如纸、声如磬'
      },
    ],
    leftList2:[],
    rightList2:[],
    shoppingList3:[
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/帆布包.jpg',
        title:'清雅帆布包',
        price:'22.9',
        details:'有多重品类可选'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/瓷碗.jpg',
        title:'小瓷器',
        price:'39.9',
        details:'品质摆件'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/守味狸香囊.jpg',
        title:'守味狸香囊',
        price:'9.9',
        details:'精美周边'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/印章明信片.jpg',
        title:'印章明信片',
        price:'12.9',
        details:'一盒装'
      },
      {
        imgSrc:'https://main-bucket-1317028681.cos.ap-guangzhou.myqcloud.com/images/杜甫江阁画作.jpg',
        title:'杜甫江阁画作',
        price:'45.9',
        details:'挂饰'
      }
    ],
    leftList3:[],
    rightList3:[],
    //页面滑动距离
    scrollTop:0,
    //顶部导航栏透明度
    titleOpacity:'0',
  },

  //swiper滑动事件
  swiperChange: function (e) {  //指示图标
    this.setData({
      swiperCurrent: e.detail.current
    })
  },
  tabNav(e) {
    let currentTab = e.currentTarget.dataset.current
    this.setData({
      currentTab
    })
  },
  changeNav(e) {
    let {current,source} = e.detail
    if (source === 'autoplay' || source === 'touch') {
      const currentTab = current
      this.setData({
        currentTab
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.twoSidesCompoute();
  },
  // 计算商街的两栏各放几个item
  twoSidesCompoute(){
    var itemsNum1 = this.data.shoppingList1.length;
    var itemsNum2 = this.data.shoppingList2.length;
    var itemsNum3 = this.data.shoppingList3.length;
    this.setData({
      leftList1:this.data.shoppingList1.slice(0,Math.trunc(itemsNum1/2)),
      rightList1:this.data.shoppingList1.slice(Math.trunc(itemsNum1/2)),
      leftList2:this.data.shoppingList2.slice(0,Math.trunc(itemsNum2/2)),
      rightList2:this.data.shoppingList2.slice(Math.trunc(itemsNum2/2)),
      leftList3:this.data.shoppingList3.slice(0,Math.trunc(itemsNum3/2)),
      rightList3:this.data.shoppingList3.slice(Math.trunc(itemsNum3/2)),
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  //监听屏幕滚动 判断上下滚动
  onPageScroll: function (ev) {
    this.setData({
      scrollTop: ev.scrollTop
    });
    // num决定滚动时导航栏显示的快慢
		let num = 160;
    let r = ev.scrollTop  / num;
    let opacity = r>=1?1:r;
    this.titleOpacity = 'opacity:' +opacity;
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})